const api = ({name,action,params})=>{
	return new Promise((resolve,reject)=>{
		uniCloud.callFunction({
			name,
			data:{
				action,
				params
			},
			success: ({result}) => {
				if(result.code===0) resolve(result)
				else{
					uni.showToast({
						title:result.errMsg,
						icon:'none',
						duration:2000
					})
					reject(result)
				}
			},
			fail: (err) => {
				uni.showToast({
					title:result.errMsg||'请求超时',
					icon:'none',
					duration:2000
				})
			}
		})
	})
}

export default api